import { _decorator, BoxCollider2D, Component, Node, RigidBody, RigidBody2D, Sprite, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('GreenBall')
export class GreenBall extends Component {

    @property(SpriteFrame)
    greenBallSp: SpriteFrame;

    eated() {
        this.node.getChildByName("sp").getComponent(Sprite).spriteFrame = null;
        this.node.getComponent(BoxCollider2D).enabled = false;
        this.node.getComponent(RigidBody2D).enabled = false;
        this.scheduleOnce(() => {
            this.node.getChildByName("sp").getComponent(Sprite).spriteFrame = this.greenBallSp;
            this.node.getComponent(BoxCollider2D).enabled = true;
            this.node.getComponent(RigidBody2D).enabled = true;
        }, 5)
    }

    poolGetInit(){
        this.unscheduleAllCallbacks();
        this.node.getChildByName("sp").getComponent(Sprite).spriteFrame = this.greenBallSp;
        this.node.getComponent(BoxCollider2D).enabled = true;
        this.node.getComponent(RigidBody2D).enabled = true;
    }

    poolPushInit(){
        this.unscheduleAllCallbacks();
    }


}


